import { defineStore } from "pinia"

// 1.定义并导出容易
// 参数1：容器的 ID,必须唯一，将来 Pinia 会把所有的容器挂载到跟容器
export const useChatStore = defineStore('chat', {
  /**
   * 类似于组件的 data,用来存储全局状态
   */
  state: () => {
    return {
      info:'',
      form:'',
      deviceName:'',
      chatState:false
    }
  },
  /**
   * 类似组件的 methods,封装业务逻辑，修改 state
   */
  actions: {
    setChatInfo(info:string,deviceName:string){
      this.info  = info
      this.deviceName = deviceName
    },
    setCurrentNode(form:any){
      this.form = form
    },
    setChatState(state:boolean){
      this.chatState = state
    }
  },
})